import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
//挂载Vuex
Vue.use(Vuex)


//创建VueX对象
const store = new Vuex.Store({
  state: {
    //存放的键值对就是所要管理的状态
    name: 'helloVueX',

    //节气养生的数据开始
    current_page: 1, //当前页
    pages: 50, //总页数
    // changePage: '',//跳转页
    pageSum: 6,//每页大小
    // nowIndex: 0,
    show_ul: false,
    selectStateValue: '',
    jumpTo: 1,
    searchTitle: '',
    record:null,
    records: [],
    showTip: false,

    //节气养生的数据结束


  },
  getters: {
    getDemoValue: state => state.records


  },
  mutations: {
    setRecord(state, value) {

      state.record=value;
    },
    setShowTip() {
      this.state.showTip = !this.state.showTip;

      let that = this;
      setTimeout(function () {
        that.state.showTip = !that.state.showTip;

      },1500);

    },


    setCurrent_page(state, value) {
      this.state.current_page = value;
    },

    setPages(state, pagesValue) {
      this.state.pages = pagesValue;
    },
    setPageSum(state, value) {
      this.state.pageSum = value;
    },
    setShow_ul(state) {
      this.state.show_ul = !this.state.show_ul;
    },


    setSelectStateValue(state, value) {
      this.state.selectStateValue = value;
    },

    setRecords(state, records) {
      this.state.records = records;

    },
    setRecordsByAXIOS(state) {
      axios.get('http://localhost:8071/getHealthPreservationByHotspotTitle?current=' + state.current_page + '&limit=' + state.pageSum + "&hotspotTitle=" + state.searchTitle).then((res) => {
        state.pages = res.data.pages;
        state.records = res.data.records;
        // this.$store.commit('setPages', res.data.pages);
        // this.$store.commit('setRecords', res.data.records);
      });
    },
    submitph(state,v1,v2){
      axios.get('http://localhost:8071/updateTbNatmehaHotspotHealthPreservationStatus?itemcode=' + v1+ '&status=' + v2 ).then((res) => {
        this.$store.commit('setRecordsByAXIOS');
      });
    }



  },
  actions: {}
});

export default store
